﻿using HtmlAgilityPack;
using ProcessLib.Ratp.Easy.Breaker;
using ProcessLib.Ratp.Easy.Extension;
using ProcessLib.Ratp.Easy.Mark;
using ProcessLib.Ratp.Easy.ParagraphCompose;
using ProcessLib.Ratp.Easy.Select;
using ProcessLib.Ratp.Page.Processors;
using StyleSharp.Styles;

namespace ProcessLib.Ratp.Easy;

public class Easy
{
    public static void Output()
    {
        var path = @"C:\Users\betha\WebstormProjects\monaco\code_pdf2htmlex.html";
        var docText = File.ReadAllText(path);
        var composer = new Composer(docText);
        var styleNode = composer.StyleNode;
        styleNode.BuildAllXYHF();
        var document = new HtmlDocument();
        document.LoadHtml(composer.MainContainer);
        var page = PageParting.GetPages(document);

        var pf1 = DivHelpSelector.Select(page[0].Document, "div");
        var pf1Text = pf1.OuterHtml;
        var c2 = new PageComposer(styleNode, pf1Text);
        var pageHtml = c2.Compose();
        var htmlhtml = composer.OutHtmlOneStep(new List<string>(){pageHtml});
        File.WriteAllText(@"C:\Users\betha\RiderProjects\StyleSharp\ProcessLib\resources\out.html",
            $"{htmlhtml}");
        Console.WriteLine("Finished");




        // pas.ListElements();

        // pf1.Attributes.Add(Rtp.TranslateAttr,"tr001");
        // pf1.Attributes.Add(Rtp.WholeAttr,"");
        // Console.WriteLine(pf1.OuterHtml);
        // var node = pf1.SelectSingleNode("//div[contains(@class,'t')]");
        // Console.WriteLine(node.OuterHtml);
        // var str = node.GetAttribute("class");
        // Console.WriteLine($"str: {str}");
        // Console.WriteLine($"x: {Extractor.ExtractorX(str)}");
        // Console.WriteLine($"y: {Extractor.ExtractorY(str)}");
        // Console.WriteLine($"H: {Extractor.ExtractorHeight(str)}");
        // Console.WriteLine($"FS: {Extractor.ExtractorFontSize(str)}");
        // Console.WriteLine($"FF: {Extractor.ExtractorFontFamily(str)}");
        // styleNode.FontFamilies.ListElements();
        // styleNode.Lefts.ListElements();
        // styleNode.Bottoms.ListElements();
        // styleNode.Heights.ListElements();
        // styleNode.FontSizes.ListElements();

    }
}